home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / system-config-printer / troubleshoot / NetworkCUPSPrinterShared.py < prev    next >
Encoding:
Python Source  |  2009-05-05  |  2.8 KB  |  78 lines

  1. #!/usr/bin/env python
  2.  
  3. ## Printing troubleshooter
  4.  
  5. ## Copyright (C) 2008 Red Hat, Inc.
  6. ## Copyright (C) 2008 Tim Waugh <twaugh@redhat.com>
  7.  
  8. ## This program is free software; you can redistribute it and/or modify
  9. ## it under the terms of the GNU General Public License as published by
  10. ## the Free Software Foundation; either version 2 of the License, or
  11. ## (at your option) any later version.
  12.  
  13. ## This program is distributed in the hope that it will be useful,
  14. ## but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. ## GNU General Public License for more details.
  17.  
  18. ## You should have received a copy of the GNU General Public License
  19. ## along with this program; if not, write to the Free Software
  20. ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22. import cups
  23. from timedops import TimedOperation
  24. from base import *
  25. class NetworkCUPSPrinterShared(Question):
  26.     def __init__ (self, troubleshooter):
  27.         Question.__init__ (self, troubleshooter, "Queue not shared?")
  28.         page = self.initial_vbox (_("Queue Not Shared"),
  29.                                   _("The CUPS printer on the server is not "
  30.                                     "shared."))
  31.         troubleshooter.new_page (page, self)
  32.  
  33.     def display (self):
  34.         self.answers = {}
  35.         answers = self.troubleshooter.answers
  36.         if (answers.has_key ('remote_cups_queue_listed') and
  37.             answers['remote_cups_queue_listed'] == False):
  38.             return False
  39.  
  40.         parent = self.troubleshooter.get_window ()
  41.         if not answers.has_key ('remote_cups_queue_attributes'):
  42.             if not (answers.has_key ('remote_server_try_connect') and
  43.                     answers.has_key ('remote_cups_queue')):
  44.                 return False
  45.  
  46.             try:
  47.                 cups.setServer (answers['remote_server_try_connect'])
  48.                 self.op = TimedOperation (cups.Connection, parent=parent)
  49.                 c = self.op.run ()
  50.                 self.op = TimedOperation (c.getPrinterAttributes,
  51.                                           args=(answers['remote_cups_queue'],),
  52.                                           parent=parent)
  53.                 attr = self.op.run ()
  54.             except RuntimeError:
  55.                 return False
  56.             except cups.IPPError:
  57.                 return False
  58.  
  59.             self.answers['remote_cups_queue_attributes'] = attr
  60.         else:
  61.             attr = answers['remote_cups_queue_attributes']
  62.  
  63.         if attr.has_key ('printer-is-shared'):
  64.             # CUPS >= 1.2
  65.             if not attr['printer-is-shared']:
  66.                 return True
  67.  
  68.         return False
  69.  
  70.     def can_click_forward (self):
  71.         return False
  72.  
  73.     def collect_answer (self):
  74.         return self.answers
  75.  
  76.     def cancel_operation (self):
  77.         self.op.cancel ()
  78.